/**
 * Layout component that queries for data
 * with Gatsby's useStaticQuery component
 *
 * See: https://www.gatsbyjs.com/docs/use-static-query/
 */

import * as React from "react"
import PropTypes from "prop-types"
import { Link, useStaticQuery, graphql } from "gatsby"
import { StaticImage } from "gatsby-plugin-image"
import "../less/layout.less"
import { Layout, Menu, Space } from 'antd'
const { Header, Footer, Content } = Layout

const LayoutDefault: React.FC = ({ children }) => {
  const data = useStaticQuery(graphql`
    query SiteTitleQuery {
      site {
        siteMetadata {
          title
        }
      }
    }
  `)

  return (
    <Layout className="layout">
      <Header className="header">
        <Link to="/" className="logo">
          <StaticImage
            src="../images/3pixel_logo.png"
            width={110}
            formats={["auto", "webp", "avif"]}
            alt={data.site.siteMetadata?.title || `Title`}
          />
        </Link>
        <Menu
          className="menu"
          theme="dark"
          mode="horizontal">
          <Menu.Item key="1">
            <Link to="/" activeClassName="cur">首页</Link>
          </Menu.Item>
          <Menu.Item key="2">
            <Link to="/html" activeClassName="cur">Html</Link>
          </Menu.Item>
        </Menu>
      </Header>
      <Content className="content">
        {children}
      </Content>
      <Footer className="footer">
        <Space direction="vertical">
          <div>© {new Date().getFullYear()} <a href="https://beian.miit.gov.cn">陕ICP备14011119号-2</a></div>
          <Space>
            博客支持:
            <a href="https://www.gatsbyjs.com">Gatsby</a>
            <a href="https://react.docschina.org/">React</a>
            <a href="https://ant.design/index-cn">Ant Desgin</a>
            <a href="https://www.tslang.cn/">TypeScript</a>
          </Space>
        </Space>
      </Footer>
    </Layout>
  )
}

LayoutDefault.propTypes = {
  children: PropTypes.node.isRequired,
}

export default LayoutDefault
